/*
 * Copyright (C) 2014 - present Instructure, Inc.
 *
 * This file is part of Canvas.
 *
 * Canvas is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License as published by the Free
 * Software Foundation, version 3 of the License.
 *
 * Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License along
 * with this program. If not, see <http://www.gnu.org/licenses/>.
 */

$gradebook_letter-grade-font: lighten($ic-color-dark, 8%);

a#accessibility_warning {
  @include accessibility-prompt;
  @include fontSize(14px);
}

#footer {
  display: none;
}

#keyboard-shortcuts:focus {
  margin: -1px;
  border-radius: 0.25rem;

  // from app/stylesheets/vendor/bootstrap/_forms.scss .uneditable-input:focus
  border: 1px solid $ic-link-color-lightened-10;
  outline: 0;
}

$row-height: 35px;
$cell_height: 33px;
$header-height: 38px;
$header-content-height: $header-height - 2px; // subtract border

$grid-border-color: #c7cdd1;
$active-border-color: #1790df;

$gradebook_cell_padding_top: 8px;

/* GridSupport Styles */

.slick-row .slick-cell.active.primary-column {
  border: 1px solid $active-border-color;
  height: $row-height - 2px;
}

.slick-row .slick-cell.active:not(.primary-column) {
  border: 2px solid $active-border-color;
  height: $row-height - 4px;
}

.slick-row.active .slick-cell.primary-column {
  background-color: $ic-bg-light-primary;
}

.container_0,
.container_1 {
  .slick-header.ui-state-default { // header container with full width of grid
    background: transparent;
    border: none;
  }

  .slick-cell { // each cell of the body
    border-bottom: 1px solid $grid-border-color;
    border-right: 1px solid $grid-border-color;
    padding: 0;
    overflow: visible;

    &.editable {
      background: transparent;
    }
  }
}

.container_0 {
  .slick-header-column:first-child {
    border-left: 1px solid $grid-border-color;
    padding-left: 0px;
  }

  .slick-cell:first-child {
    border-left: 1px solid $grid-border-color;
  }
}

.slick-cell {
  &.active {
    box-shadow: 0 0.1875rem 0.375rem rgba(0, 0, 0, 0.1), 0 0.1875rem 0.375rem rgba(0, 0, 0, 0.16);
    z-index: 5;

    &.assignment-group-cell .gradebook-cell {
      padding-top: $gradebook_cell_padding_top - 1px; // subtract extra 1px top border
    }

    &.total_grade .gradebook-cell {
      padding-top: $gradebook_cell_padding_top - 1px; // subtract extra 1px top border
    }

    &.assignment .gradebook-cell {
      padding-top: $gradebook_cell_padding_top - 2px; // subtract 2px top border
      height: $row-height - $gradebook_cell_padding_top - 3px;

      &.gradebook-cell-out-of-formatter {
        height: $row-height - 4px;
        padding-top: 0;
      }
    }
  }

  &:not(.active) {
    &.assignment .gradebook-cell {
      padding-top: $gradebook_cell_padding_top - 1px; // subtract extra 1px top border
    }
  }

  &.custom_column {
    &:not(.active) {
      border-top: 0;
      height: $row-height - 4px;
      padding-top: 2px;
      padding-bottom: 1px;
    }

    color: #333333;
    @include fontSize(12px);
    text-align: center;
    line-height: 35px;
  }
}

.slick-row.active {
  .slick-cell:not(.active) {
    &.custom_column {
      height: $row-height - 4px;
      padding-top: 1px;
      padding-bottom: 1px;
    }
  }
}

.slick-cell.meta-cell {
  padding: 0;
}

.gradebook .ic-Layout-contentMain {
  position: relative;
  padding: 0 $ic-sp*2;
}

#gradebook-grid-wrapper {
  position: relative;
}

.student-name {
  color: #1b7eda;
  text-shadow: #fbf8f8 0 0 1px;
}

.student-grades-link {
  @if $use_high_contrast { color: $ic-link-color-darkened-10; }
}

.student-placeholder {
  display: none;
}

.secondary-info {
  margin-top: -5px;
  @include fontSize(12px);
}

.student-name,
.secondary-info,
.student-section,
.student-placeholder,
.Gradebook__ColumnHeaderDetail > * {
  overflow: hidden;
  text-overflow: ellipsis;
}

// override the default jquery ui top border
.slick-header.ui-state-default {
  border-top: 0;
}

.slick-header-column {
  background-color: $ic-bg-light-neutral;
  background-image: none;
  @include fontSize(12px);
  text-align: center;
  font-weight: normal;

  // override jqueryUI style
  &.ui-state-default {
    border-top: 1px solid $grid-border-color;
    border-right: 1px solid $grid-border-color;
    border-bottom: 1px solid $grid-border-color;
    border-left: none;
    height: $header-content-height;
    padding-bottom: 0;
    padding-left: 1px;
    padding-right: 0;
    padding-top: 0;
  }

  &.hovered-column, // an element in the column is being hovered
  &.slick-header-column-active, // the column is being dragged or resized
  &.ui-state-hover {
    background-color: $ic-bg-light-primary;
  }
  .slick-column-name {
    font-weight: bold;
    color: #2f2a34;
    text-shadow: white 0 0 1px;
  }
  .assignment-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .Gradebook__ColumnHeaderContent {
    display: flex;
    width: 100%;
    height: 36px;
  }

  .Gradebook__ColumnHeaderDetail,
  .Gradebook__ColumnHeaderAction {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .Gradebook__ColumnHeaderDetail {
    flex-grow: 1;
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .Gradebook__ColumnHeaderAction {
    flex-shrink: 0;
    flex-grow: 0;
    height: $cell_height;
    opacity: 0;

    &:focus, &:hover, &.menuShown {
      opacity: 1;
    }
  }

  &:hover .Gradebook__ColumnHeaderAction {
    opacity: 1;
  }
}

.odd .slick-cell {
  background-color: #f5f6f7;
}

.even .slick-cell {
  background-color: #fcfcfc;
}

.odd .meta-cell {
  background-color: #eff3f4;
}

.even .meta-cell {
  background-color: #e6eaec;
}

.odd .total-cell {
  background-color: #e0e6e8;
}

.even .total-cell {
  background-color: #d7dee1;
}

// overrides of jqueryUI theme
.slick-row.ui-state-active {
  color: inherit;
  background-image: none;
  font-weight: normal;
  border: none;
}

.slick-row {
  &.active {
    .slick-cell:not(.active) {
      border-bottom: 1px solid $active-border-color;
      border-top: 1px solid $active-border-color;
      height: $row-height - 2px; // subtract top and bottom border
    }

    .slick-cell.primary-column {
      border-left: 1px solid $active-border-color;
      border-right: 1px solid $active-border-color;
      height: $row-height - 2px; // subtract top and bottom border
    }
  }
}

.container_1 {
  .slick-row.active {
    .slick-cell:not(.active):last-child {
      border-right: 1px solid $active-border-color;
    }
  }
}

// my styles
.slick-row.ui-state-active  .slick-cell {
  background-color: #dfe9f2;
}

.slick-cell.editable {
  border-color: $active-border-color;
}

.slick-cell.ungraded {
  background-image: url("/images/4_percent_opacity.png");
  background-repeat: repeat;
}

@mixin first-row-tooltip() {
  top: 35px;
  &:after {
    display: none;
  }
  &:before {
    border-color: #444444 transparent;
    border-style: solid;
    border-width: 5px 5px 0;
    position: absolute;
    width: 0;
    left: 15px;
    content: "";
    border-top-color: transparent;
    border-left-color: transparent;
    border-right-color: transparent;
    border-bottom: 5px solid #444444;
    top: -10px;
  }
}

.gradebook-tooltip {
  visibility: hidden;
  opacity: 0;
  background-color: #444444;
  color: white;
  border-radius: 3px;
  padding: 5px 10px;
  z-index: 7;
  position: absolute;
  font-size: 0.8em;
  left: 0;
  top: -30px;
  line-height: 1rem;
  &:after {
    border-color: #444444 transparent;
    border-style: solid;
    border-width: 5px 5px 0;
    position: absolute;
    bottom: -5px;
    width: 0;
    left: 15px;
    content: "";
  }
  .slick-cell.hover &, .slick-cell.focus &, .slick-cell.selected & {
    visibility: visible;
    opacity: 1;
  }
  .slick-cell.active &, .slick-cell.editable & {
    visibility: visible;
    opacity: 1;
  }
  &.first-row {
    @include first-row-tooltip();
  }
}

.slick-row.first-row {
  .gradebook-tooltip {
    @include first-row-tooltip();
  }
}

.total-column-tooltip {
  width: 250px;
  height: 60px;
  white-space: pre-line;
  padding-top: 5px;
  padding-bottom: 55px;
  margin-bottom: -50px;
}

.slick-cell.completely-hidden {
  display: none;
}

.container_1 .slick-cell:last-child .gradebook-tooltip {
  left: auto;
  right: 0;

  &:after {
    left: auto;
    right: 15px;
  }
}

.gradebook-cell {
  padding-top: $gradebook_cell_padding_top;
  height: $cell_height - $gradebook_cell_padding_top;
  position: relative;
  text-align: center;
  border: none;

  &.grayed-out {
    background-color: $grayLighter;
  }
}

.gradebook-cell-turnitin {
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 1;
  width: 20px;
  height: 16px;
  &.no-score {
    background-image: url(/images/turnitin_no_score.png);
  }
  &.none-score {
    background-image: url(/images/turnitin_none_score.png);
  }
  &.acceptable-score {
    background-image: url(/images/turnitin_acceptable_score.png);
  }
  &.warning-score {
    background-image: url(/images/turnitin_warning_score.png);
  }
  &.problem-score {
    background-image: url(/images/turnitin_problem_score.png);
  }
  &.failure-score {
    background-image: url(/images/turnitin_failure_score.png);
  }
  &.pending-score {
    background-image: url(/images/turnitin_submission_pending.png);
  }
  &.error-score {
    background-image: url(/images/turnitin_submission_error.png);
  }
}

.gradebook-cell-editable {
  height: $cell_height - 8px;
  padding-top: 8px;
  margin: 0;
  background-color: white;
}

.slick-cell {
  z-index: auto;

  &.active {
    background-color: inherit;
    z-index: 5;

    &.editable {
      top: 0;
    }
  }
}

.gradebook-cell {
  .grade {
    border: none;
    text-align: center;
    outline: none;
    @include fontSize(12px);
    width: 100%;
    padding: 0;
    margin: 0;
    background: none;
    box-shadow: none !important;
  }
  .grade::-webkit-outer-spin-button {
    display: none;
  }
  .grade::-ms-clear {
    display: none;
  }
}

.gradebook-cell-out-of-formatter {
  padding-top: 0;
  height: $cell_height;

  .overflow-wrapper {
    overflow: hidden;
    position: relative;
    width: 100%;
    height: $cell_height;
  }

  .grade-and-outof-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 400px;
    margin-left: -200px;
    //changeme
    margin-top: -10px;
    .divider {
      padding: 0 1px 0 2px;
    }
    .outof, .grade {
      width: 200px;
      display: inline-block;
      background: transparent;
    }
    .outof {
      user-select: none;
      text-align: left;
      // if high contrast, no color value (default to regular dark text color)
      @if $use_high_contrast == false { color: #888888; }
    }
    .grade {
      border: none;
      text-align: right;
      outline: none;
      @include fontSize(12px);
    }
    .grade::-webkit-outer-spin-button {
      display: none;
    }
  }
}

$gradebook_checkbox_size: 16px;

.gradebook-checkbox {
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  margin-top: -($gradebook_checkbox_size / 2) - ( $gradebook_cell_padding_top / 2 );
  margin-left: -$gradebook_checkbox_size / 2;
}

.Grid__AssignmentRowCell {
  display: flex;
  flex-direction: row;
  height: $cell_height;
  line-height: $cell_height;
}

.Grid__AssignmentRowCell__Notifications {
  flex-grow: 0;
  flex-shrink: 0;
  width: $cell_height;
}

.Grid__AssignmentRowCell__Content {
  flex-grow: 1;
}

.Grid__AssignmentRowCell__Options {
  flex-grow: 0;
  flex-shrink: 0;
  width: $cell_height;
}

.slick-cell.active {
  .Grid__AssignmentRowCell {
    height: $row-height - 4px;
    line-height: $row-height - 4px;
  }
}

#hide_warning {
  vertical-align: top;
}

.minimized {
  background-image: url("/images/4_percent_opacity.png");
  .gradebook-cell {
    font-size: 0px;
    * {
      display: none;
    }
  }
}

.minimized .slick-column-name {
  display: none;
}

// STUFF FOR HEADER
#gradebook-toolbar {
  position: relative;
  padding: $ic-sp 0;
  border-top: none;
  @include breakpoint(desktop) {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
}

.section-button-placeholder {
  display: inline-block;
}

.gradebook-menus {
  display: inline-block;
  flex: 0 1 auto;
}

#gradebook-actions {
  display: flex;
  flex: 1 1 auto;
  flex-direction: row;
  justify-content: flex-end;
}

.gradebook-filter-container {
  display: inline-block;
  flex: 0 1 auto;
  margin-left: $ic-sp/2;
}

.gradebook_filter {
  display: inline-block;
  margin-left: $ic-sp/2;

  input {
    width: 248px;
  }
}

.gradebook_menu {
  margin-left: $ic-sp/2;
  flex: 0 1 auto;

  @include breakpoint(desktop) {
    white-space: nowrap;
    text-align: right;
  }
}

@mixin gradebook_menu_label($fontsize) {
  font-size: $fontsize;
  font-weight: bold;
  margin-bottom: 0;
  vertical-align: 0px !important;
  position: relative;
  line-height: 1.5;
}

#section-to-show-menu {
  width: 350px;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 275px;
  label {
    @include gradebook_menu_label(12px);
  }
  .ui-state-focus:last-child {
    margin: 0 !important;
  }
}

.post-grades-placeholder {
  display: inline-block;
}

.submission_type_icon {
  display: block;
  width: 100%;
  height: 22px;
  background-position: center center;
  background-repeat: no-repeat;
  .online_text_entry & {
    background-image: url("/images/text_entry.png");
  }
  .discussion_topic & {
    background-image: url("/images/word_bubble.png");
  }
  .online_upload & {
    background-image: url("/images/file.png");
  }
  .pending_review & {
    background-image: url("/images/pending_review.png");
  }
  .media_comment &, .media_recording & {
    background-image: url("/images/media_comment.gif");
  }
  .quiz & {
    background-image: url("/images/quiz.png");
  }
}

.letter-grade-points,
.gpa-scale-points {
  position: absolute;
  @include fontSize(12px);
  padding-left: 8px;
  line-height: 19px;
  color: $gradebook_letter-grade-font;
  .muted & {
    @if $use_high_contrast { color: darken($ic-hint-text, 20%); }
    @else { color: $ic-hint-text; }
  }

  .total_grade & {
    position: static;
  }
}

.final-warning {
  margin-left: -16px;
}

.gradebook_dropdown, .export_dropdown {
  li, label {
    @include gradebook_menu_label(13px);
    cursor:pointer;
  }
}

.ui-menu .ui-menu-item.ui-state-disabled {
  padding: 0;
  margin: 0;
  line-height: 1;
}

.ui-menu-item.ui-state-disabled label {
  margin-bottom: 0;
  vertical-align: 0;
}

.post-grades-menu {
  li.external-tools-dialog,
  li.post-grades-placeholder {
    cursor: pointer;
  }
  li.external-tools-dialog.ellip {
    cursor: default;
  }
}

.ui-dialog.post-grades-frame-dialog {
  .ui-dialog-content {
    padding: 0;
    overflow: hidden;
  }
}

#export_progress {
  background-color: gray;
  width: 100px;
  height: 8px;
  margin: auto;

  div {
    position: relative;
    left: 0;
    width: 20px;
    height: 8px;
    background: blue;
  }
}

// Very specific declaration to get Choose a Section text to have better text:background contrast in Section dropdown
#section-to-show-menu {
  li:first-of-type.ui-state-disabled {
    opacity: 0.8;
  }
}

.Gradebook__StatusModalListItem {
  padding: 7px;
  margin-bottom: 5px;
  border: 1px solid #C7CDD1;
  border-radius: 3px;
}

.Gradebook__StatusModalList {
  margin: 0px;
  list-style-type: none;
}

.ComingSoonContent__Container {
  text-align: center;
}

.ComingSoonContent__Body {
  display: inline-block;
  margin-top: 2rem;
}

#LatePoliciesTabPanel__Container-noContent {
  text-align: center;
  min-height: 30rem;
}

#LatePoliciesTabPanel__Container {
  min-height: 30rem;
  display: flex;
  justify-content: space-around;
  flex-direction: column;

  input[type="text"] {
    height: auto;
    line-height: 1;
    margin: 0;
    padding: auto;
    box-shadow: none;
    border: none;
  }
}

.NumberInput__Container {
  display: flex;
  align-items: center;
}

.NumberInput__Container-LeftIndent {
  margin-left: 1.5rem
}

.SubmissionTray__Container {
  box-sizing: border-box;
  height: 100%;
  padding: 1.5rem;

  input[type="text"] {
    height: auto;
    line-height: 1;
    margin: 0;
    padding: auto;
    box-shadow: none;
    border: none;
  }
}

.SubmissionTray__RadioInput {
  padding: 0.4rem;
  margin-bottom: 0.4rem;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
}

.SubmissionTray__RadioInput-WithBackground {
  border: 1px solid $ic-border-color;
  border-radius: 0.25rem;
}

#SubmissionTray__Content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#SubmissionTray__Avatar {
  min-height: 2rem;
  padding: 0.7rem;
  text-align: center;
  font-size: 1.375rem;
}

#SubmissionTray__Comments {
  line-height: 1;
}

#SubmissionTray__StudentName {
  text-align: center;
  padding: 0.7rem;
}
